
package com.javafactroy.kunlong.codegen.generator;


import com.javafactroy.kunlong.codegen.model.DomainEntity;
import com.javafactroy.kunlong.codegen.util.TemplateHelper;
import com.javafactroy.kunlong.codegen.context.AppContext;
import com.javafactroy.kunlong.codegen.model.ServiceImplEntity;
import freemarker.template.Template;
import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;


public class ControllerClassGenerator {

    public void generate(String tableName, String entityName, String entityPkg ) throws IOException, TemplateException {
        /* 19 */
        Template tpl = TemplateHelper.getInstance().getTemplate("controller.java.tpl");

        /* 21 */
        DomainEntity domainEntity = EntityClassGenerator.getDomainEntity(tableName, entityName, entityPkg);

        /* 23 */
        ///DaoEntity daoEntity = MapperClassGenerator.getDaoEntity(domainEntity, daoPkg);

        //ServiceEntity serviceEntity = ServiceClassGenerator.getServiceEntity(daoEntity, servicePkg);

        //serviceEntity.addImport(serviceEntity.getFullname());


       // File dstFile = AppContext.getGenerateTargetFile(serviceEntity.getPkgName(), String.valueOf(serviceEntity.getClassName()) + ".java");

       // TemplateHelper.write2File(tpl, serviceEntity, dstFile);
        // JOptionPane.showMessageDialog(null, "生成Service异常[tableName:" + tableName + "]:" + e.getMessage());


        /* 40 */
        ServiceImplEntity entity = new ServiceImplEntity();
        /* 41 */
        //entity.setClassName(String.valueOf(serviceEntity.getClassName()) + "Impl");

        //entity.setPkgName(String.valueOf(serviceEntity.getPkgName()) + ".impl");

       // entity.setServiceEntity(serviceEntity);

        entity.setDomainEntity(domainEntity);

        //entity.setDaoEntity(daoEntity);

        entity.addImport("org.springframework.beans.factory.annotation.Autowired");

        entity.addImport("org.springframework.stereotype.Service");

        entity.addImport(String.valueOf(entityPkg) + "." + domainEntity.getClassName());

      //  entity.addImport(String.valueOf(daoEntity.getPkgName()) + "." + daoEntity.getClassName());

      //  entity.addImport(String.valueOf(serviceEntity.getPkgName()) + "." + serviceEntity.getClassName());


        tpl = TemplateHelper.getInstance().getTemplate("service.impl.java.tpl");


        File dstFile = AppContext.getGenerateTargetFile(entity.getPkgName(), String.valueOf(entity.getClassName()) + ".java");


        TemplateHelper.write2File(tpl, entity, dstFile);


        //JOptionPane.showMessageDialog(null, "生成ServiceImpl异常[tableName:" + tableName + "]:" + e.getMessage());


    }

}


/* Location:              hbatis-codegen.jar!\com\pitaya\codegen\generator\ControllerClassGenerator.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.2
 */